using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace LMSData
{
	/// <summary>
	/// Strongly-typed collection for the AuditLogin class.
	/// </summary>
	[Serializable]
	public partial class AuditLoginCollection : ActiveList<AuditLogin, AuditLoginCollection> 
	{	   
		public AuditLoginCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the AuditLogin table.
	/// </summary>
	[Serializable]
	public partial class AuditLogin : ActiveRecord<AuditLogin>
	{
		#region .ctors and Default Settings
		
		public AuditLogin()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public AuditLogin(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public AuditLogin(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public AuditLogin(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("AuditLogin", TableType.Table, DataService.GetInstance("LMS"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarAuditLoginID = new TableSchema.TableColumn(schema);
				colvarAuditLoginID.ColumnName = "AuditLoginID";
				colvarAuditLoginID.DataType = DbType.Int32;
				colvarAuditLoginID.MaxLength = 0;
				colvarAuditLoginID.AutoIncrement = true;
				colvarAuditLoginID.IsNullable = false;
				colvarAuditLoginID.IsPrimaryKey = true;
				colvarAuditLoginID.IsForeignKey = false;
				colvarAuditLoginID.IsReadOnly = false;
				colvarAuditLoginID.DefaultSetting = @"";
				colvarAuditLoginID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarAuditLoginID);
				
				TableSchema.TableColumn colvarUserID = new TableSchema.TableColumn(schema);
				colvarUserID.ColumnName = "UserID";
				colvarUserID.DataType = DbType.Int32;
				colvarUserID.MaxLength = 0;
				colvarUserID.AutoIncrement = false;
				colvarUserID.IsNullable = true;
				colvarUserID.IsPrimaryKey = false;
				colvarUserID.IsForeignKey = false;
				colvarUserID.IsReadOnly = false;
				colvarUserID.DefaultSetting = @"";
				colvarUserID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUserID);
				
				TableSchema.TableColumn colvarUserName = new TableSchema.TableColumn(schema);
				colvarUserName.ColumnName = "UserName";
				colvarUserName.DataType = DbType.String;
				colvarUserName.MaxLength = 255;
				colvarUserName.AutoIncrement = false;
				colvarUserName.IsNullable = true;
				colvarUserName.IsPrimaryKey = false;
				colvarUserName.IsForeignKey = false;
				colvarUserName.IsReadOnly = false;
				colvarUserName.DefaultSetting = @"";
				colvarUserName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUserName);
				
				TableSchema.TableColumn colvarPlatform = new TableSchema.TableColumn(schema);
				colvarPlatform.ColumnName = "Platform";
				colvarPlatform.DataType = DbType.String;
				colvarPlatform.MaxLength = 255;
				colvarPlatform.AutoIncrement = false;
				colvarPlatform.IsNullable = true;
				colvarPlatform.IsPrimaryKey = false;
				colvarPlatform.IsForeignKey = false;
				colvarPlatform.IsReadOnly = false;
				colvarPlatform.DefaultSetting = @"";
				colvarPlatform.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPlatform);
				
				TableSchema.TableColumn colvarBrowser = new TableSchema.TableColumn(schema);
				colvarBrowser.ColumnName = "Browser";
				colvarBrowser.DataType = DbType.String;
				colvarBrowser.MaxLength = 255;
				colvarBrowser.AutoIncrement = false;
				colvarBrowser.IsNullable = true;
				colvarBrowser.IsPrimaryKey = false;
				colvarBrowser.IsForeignKey = false;
				colvarBrowser.IsReadOnly = false;
				colvarBrowser.DefaultSetting = @"";
				colvarBrowser.ForeignKeyTableName = "";
				schema.Columns.Add(colvarBrowser);
				
				TableSchema.TableColumn colvarBrowserVersion = new TableSchema.TableColumn(schema);
				colvarBrowserVersion.ColumnName = "BrowserVersion";
				colvarBrowserVersion.DataType = DbType.String;
				colvarBrowserVersion.MaxLength = 255;
				colvarBrowserVersion.AutoIncrement = false;
				colvarBrowserVersion.IsNullable = true;
				colvarBrowserVersion.IsPrimaryKey = false;
				colvarBrowserVersion.IsForeignKey = false;
				colvarBrowserVersion.IsReadOnly = false;
				colvarBrowserVersion.DefaultSetting = @"";
				colvarBrowserVersion.ForeignKeyTableName = "";
				schema.Columns.Add(colvarBrowserVersion);
				
				TableSchema.TableColumn colvarLoginDate = new TableSchema.TableColumn(schema);
				colvarLoginDate.ColumnName = "LoginDate";
				colvarLoginDate.DataType = DbType.DateTime;
				colvarLoginDate.MaxLength = 0;
				colvarLoginDate.AutoIncrement = false;
				colvarLoginDate.IsNullable = true;
				colvarLoginDate.IsPrimaryKey = false;
				colvarLoginDate.IsForeignKey = false;
				colvarLoginDate.IsReadOnly = false;
				colvarLoginDate.DefaultSetting = @"";
				colvarLoginDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarLoginDate);
				
				TableSchema.TableColumn colvarIPAddress = new TableSchema.TableColumn(schema);
				colvarIPAddress.ColumnName = "IPAddress";
				colvarIPAddress.DataType = DbType.String;
				colvarIPAddress.MaxLength = 255;
				colvarIPAddress.AutoIncrement = false;
				colvarIPAddress.IsNullable = true;
				colvarIPAddress.IsPrimaryKey = false;
				colvarIPAddress.IsForeignKey = false;
				colvarIPAddress.IsReadOnly = false;
				colvarIPAddress.DefaultSetting = @"";
				colvarIPAddress.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIPAddress);
				
				TableSchema.TableColumn colvarSuccess = new TableSchema.TableColumn(schema);
				colvarSuccess.ColumnName = "Success";
				colvarSuccess.DataType = DbType.Boolean;
				colvarSuccess.MaxLength = 0;
				colvarSuccess.AutoIncrement = false;
				colvarSuccess.IsNullable = true;
				colvarSuccess.IsPrimaryKey = false;
				colvarSuccess.IsForeignKey = false;
				colvarSuccess.IsReadOnly = false;
				colvarSuccess.DefaultSetting = @"";
				colvarSuccess.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSuccess);
				
				TableSchema.TableColumn colvarCreatedOn = new TableSchema.TableColumn(schema);
				colvarCreatedOn.ColumnName = "CreatedOn";
				colvarCreatedOn.DataType = DbType.DateTime;
				colvarCreatedOn.MaxLength = 0;
				colvarCreatedOn.AutoIncrement = false;
				colvarCreatedOn.IsNullable = true;
				colvarCreatedOn.IsPrimaryKey = false;
				colvarCreatedOn.IsForeignKey = false;
				colvarCreatedOn.IsReadOnly = false;
				colvarCreatedOn.DefaultSetting = @"";
				colvarCreatedOn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedOn);
				
				TableSchema.TableColumn colvarCreatedBy = new TableSchema.TableColumn(schema);
				colvarCreatedBy.ColumnName = "CreatedBy";
				colvarCreatedBy.DataType = DbType.String;
				colvarCreatedBy.MaxLength = 50;
				colvarCreatedBy.AutoIncrement = false;
				colvarCreatedBy.IsNullable = true;
				colvarCreatedBy.IsPrimaryKey = false;
				colvarCreatedBy.IsForeignKey = false;
				colvarCreatedBy.IsReadOnly = false;
				colvarCreatedBy.DefaultSetting = @"";
				colvarCreatedBy.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedBy);
				
				TableSchema.TableColumn colvarModifiedOn = new TableSchema.TableColumn(schema);
				colvarModifiedOn.ColumnName = "ModifiedOn";
				colvarModifiedOn.DataType = DbType.DateTime;
				colvarModifiedOn.MaxLength = 0;
				colvarModifiedOn.AutoIncrement = false;
				colvarModifiedOn.IsNullable = true;
				colvarModifiedOn.IsPrimaryKey = false;
				colvarModifiedOn.IsForeignKey = false;
				colvarModifiedOn.IsReadOnly = false;
				colvarModifiedOn.DefaultSetting = @"";
				colvarModifiedOn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarModifiedOn);
				
				TableSchema.TableColumn colvarModifiedBy = new TableSchema.TableColumn(schema);
				colvarModifiedBy.ColumnName = "ModifiedBy";
				colvarModifiedBy.DataType = DbType.String;
				colvarModifiedBy.MaxLength = 50;
				colvarModifiedBy.AutoIncrement = false;
				colvarModifiedBy.IsNullable = true;
				colvarModifiedBy.IsPrimaryKey = false;
				colvarModifiedBy.IsForeignKey = false;
				colvarModifiedBy.IsReadOnly = false;
				colvarModifiedBy.DefaultSetting = @"";
				colvarModifiedBy.ForeignKeyTableName = "";
				schema.Columns.Add(colvarModifiedBy);
				
				TableSchema.TableColumn colvarIsDeleted = new TableSchema.TableColumn(schema);
				colvarIsDeleted.ColumnName = "IsDeleted";
				colvarIsDeleted.DataType = DbType.Boolean;
				colvarIsDeleted.MaxLength = 0;
				colvarIsDeleted.AutoIncrement = false;
				colvarIsDeleted.IsNullable = false;
				colvarIsDeleted.IsPrimaryKey = false;
				colvarIsDeleted.IsForeignKey = false;
				colvarIsDeleted.IsReadOnly = false;
				
						colvarIsDeleted.DefaultSetting = @"((0))";
				colvarIsDeleted.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsDeleted);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["LMS"].AddSchema("AuditLogin",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("AuditLoginID")]
		public int AuditLoginID 
		{
			get { return GetColumnValue<int>("AuditLoginID"); }

			set { SetColumnValue("AuditLoginID", value); }

		}

		  
		[XmlAttribute("UserID")]
		public int? UserID 
		{
			get { return GetColumnValue<int?>("UserID"); }

			set { SetColumnValue("UserID", value); }

		}

		  
		[XmlAttribute("UserName")]
		public string UserName 
		{
			get { return GetColumnValue<string>("UserName"); }

			set { SetColumnValue("UserName", value); }

		}

		  
		[XmlAttribute("Platform")]
		public string Platform 
		{
			get { return GetColumnValue<string>("Platform"); }

			set { SetColumnValue("Platform", value); }

		}

		  
		[XmlAttribute("Browser")]
		public string Browser 
		{
			get { return GetColumnValue<string>("Browser"); }

			set { SetColumnValue("Browser", value); }

		}

		  
		[XmlAttribute("BrowserVersion")]
		public string BrowserVersion 
		{
			get { return GetColumnValue<string>("BrowserVersion"); }

			set { SetColumnValue("BrowserVersion", value); }

		}

		  
		[XmlAttribute("LoginDate")]
		public DateTime? LoginDate 
		{
			get { return GetColumnValue<DateTime?>("LoginDate"); }

			set { SetColumnValue("LoginDate", value); }

		}

		  
		[XmlAttribute("IPAddress")]
		public string IPAddress 
		{
			get { return GetColumnValue<string>("IPAddress"); }

			set { SetColumnValue("IPAddress", value); }

		}

		  
		[XmlAttribute("Success")]
		public bool? Success 
		{
			get { return GetColumnValue<bool?>("Success"); }

			set { SetColumnValue("Success", value); }

		}

		  
		[XmlAttribute("CreatedOn")]
		public DateTime? CreatedOn 
		{
			get { return GetColumnValue<DateTime?>("CreatedOn"); }

			set { SetColumnValue("CreatedOn", value); }

		}

		  
		[XmlAttribute("CreatedBy")]
		public string CreatedBy 
		{
			get { return GetColumnValue<string>("CreatedBy"); }

			set { SetColumnValue("CreatedBy", value); }

		}

		  
		[XmlAttribute("ModifiedOn")]
		public DateTime? ModifiedOn 
		{
			get { return GetColumnValue<DateTime?>("ModifiedOn"); }

			set { SetColumnValue("ModifiedOn", value); }

		}

		  
		[XmlAttribute("ModifiedBy")]
		public string ModifiedBy 
		{
			get { return GetColumnValue<string>("ModifiedBy"); }

			set { SetColumnValue("ModifiedBy", value); }

		}

		  
		[XmlAttribute("IsDeleted")]
		public bool IsDeleted 
		{
			get { return GetColumnValue<bool>("IsDeleted"); }

			set { SetColumnValue("IsDeleted", value); }

		}

		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(int? varUserID,string varUserName,string varPlatform,string varBrowser,string varBrowserVersion,DateTime? varLoginDate,string varIPAddress,bool? varSuccess,DateTime? varCreatedOn,string varCreatedBy,DateTime? varModifiedOn,string varModifiedBy,bool varIsDeleted)
		{
			AuditLogin item = new AuditLogin();
			
			item.UserID = varUserID;
			
			item.UserName = varUserName;
			
			item.Platform = varPlatform;
			
			item.Browser = varBrowser;
			
			item.BrowserVersion = varBrowserVersion;
			
			item.LoginDate = varLoginDate;
			
			item.IPAddress = varIPAddress;
			
			item.Success = varSuccess;
			
			item.CreatedOn = varCreatedOn;
			
			item.CreatedBy = varCreatedBy;
			
			item.ModifiedOn = varModifiedOn;
			
			item.ModifiedBy = varModifiedBy;
			
			item.IsDeleted = varIsDeleted;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varAuditLoginID,int? varUserID,string varUserName,string varPlatform,string varBrowser,string varBrowserVersion,DateTime? varLoginDate,string varIPAddress,bool? varSuccess,DateTime? varCreatedOn,string varCreatedBy,DateTime? varModifiedOn,string varModifiedBy,bool varIsDeleted)
		{
			AuditLogin item = new AuditLogin();
			
				item.AuditLoginID = varAuditLoginID;
				
				item.UserID = varUserID;
				
				item.UserName = varUserName;
				
				item.Platform = varPlatform;
				
				item.Browser = varBrowser;
				
				item.BrowserVersion = varBrowserVersion;
				
				item.LoginDate = varLoginDate;
				
				item.IPAddress = varIPAddress;
				
				item.Success = varSuccess;
				
				item.CreatedOn = varCreatedOn;
				
				item.CreatedBy = varCreatedBy;
				
				item.ModifiedOn = varModifiedOn;
				
				item.ModifiedBy = varModifiedBy;
				
				item.IsDeleted = varIsDeleted;
				
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string AuditLoginID = @"AuditLoginID";
			 public static string UserID = @"UserID";
			 public static string UserName = @"UserName";
			 public static string Platform = @"Platform";
			 public static string Browser = @"Browser";
			 public static string BrowserVersion = @"BrowserVersion";
			 public static string LoginDate = @"LoginDate";
			 public static string IPAddress = @"IPAddress";
			 public static string Success = @"Success";
			 public static string CreatedOn = @"CreatedOn";
			 public static string CreatedBy = @"CreatedBy";
			 public static string ModifiedOn = @"ModifiedOn";
			 public static string ModifiedBy = @"ModifiedBy";
			 public static string IsDeleted = @"IsDeleted";
						
		}

		#endregion
	}

}

